home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # to extract, remove the header and type "sh filename"
- if `test ! -s ./Makefile`
- then
- echo "writing ./Makefile"
- cat > ./Makefile << '\Rogue\Monster\'
- #########################################################################
- # #
- # Makefile for network datagram test programs. #
- # #
- #########################################################################
-
- CFLAGS = -gx
-
- LIB =
-
- BINS = ipforwarding \
-
- all: $(BINS)
-
- IPFORWARDING_OBJS = \
- ethertoa.o \
- ipforwarding.o \
- nit.o \
- tx_hostname.o
-
- ipforwarding: $(IPFORWARDING_OBJS) $(LIB)
- cc -o ipforwarding $(IPFORWARDING_OBJS) $(LIB)
-
- .c.o:; cc $(CFLAGS) -c $<
- \Rogue\Monster\
- else
- echo "will not overwrite ./Makefile"
- fi
- if [ `wc -c ./Makefile | awk '{printf $1}'` -ne 478 ]
- then
- echo `wc -c ./Makefile | awk '{print "Got " $1 ", Expected " 478}'`
- fi
- if `test ! -s ./ethertoa.3`
- then
- echo "writing ./ethertoa.3"
- cat > ./ethertoa.3 << '\Rogue\Monster\'
- .TH ETHERTOA 3 "ISTC" 25-Sep-87
- .SH NAME
- .nf
- atoether \- Translate ascii to ethernet address
- ethertoa \- Translate ethernet address to ascii
- .fi
- .SH ORIGIN
- SRI Information Science and Technology Center
- .SH SYNOPSIS
- .sp
- .ft B
- .nf
- #include <sys/types.h>
- #include <netinet/in.h>
- #include <netinet/if_ether.h>
- .sp
- int atoether(a, ea)
- char *a;
- struct ether_addr *ea;
- .sp
- extern char *ethertoa(ea)
- struct ether_addr *ea;
- .SH DESCRIPTION
- The `atoether' routine translates the string pointed to by `a' into an
- ethernet address, which is placed into the struct pointed to by `ea'.
- The string must be in the hexadecimal colon representation.
- .LP
- The `ethertoa' routine converts the ethernet address pointed to by `ea'
- to the ascii hexadecimal colon representation.
- Each octet will be zero-padded (if necessary) to two hex digits.
- A pointer to the statically stored string will be returned, copy it if
- you want to save it across subsequent calls to `ethertoa'.
- .SH DIAGNOSTICS
- The `atoether' routine will return `1' if the conversion succeeded, `0'
- otherwise.
- .SH HISTORY
- .IP 25-Nov-87 0.75i
- Written by Paul E. McKenney, SRI Information Science and Technology Center
- \Rogue\Monster\
- else
- echo "will not overwrite ./ethertoa.3"
- fi
- if [ `wc -c ./ethertoa.3 | awk '{printf $1}'` -ne 1156 ]
- then
- echo `wc -c ./ethertoa.3 | awk '{print "Got " $1 ", Expected " 1156}'`
- fi
- if `test ! -s ./ethertoa.c`
- then
- echo "writing ./ethertoa.c"
- cat > ./ethertoa.c << '\Rogue\Monster\'
- /************************************************************************
- * *
- * File: ethertoa.c *
- * *
- * ETHERnet address TO Ascii (and vice versa). *
- * *
- * Written 08-Sep-87 by Paul E. McKenney, SRI International. *
- * *
- ************************************************************************/
-
- /*
- * $Log: ethertoa.c,v $
- * Revision 2.0 88/09/23 18:27:40 mckenney
- * .
- *
- */
-
- /* Include files. */
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <net/if.h>
- #include <netinet/in.h>
- #include <netinet/if_ether.h>
-
- /* Type definitions local to this file. */
-
- /* Functions exported from this file. */
-
- extern int atoether(); /* Ascii TO ETHERnet address. */
- extern char *ethertoa(); /* ETHERnet address TO Ascii. */
-
- /* Functions local to this file. */
-
- /* Variables exported from this file. */
-
- /* Variables local to this file. */
-
-
- /* Ascii TO ETHERnet address conversion. Returns TRUE if the string */
- /* can be converted, FALSE otherwise. Address must be of form: */
- /* xx:xx:xx:xx:xx:xx */
-
- int
- atoether(a, ea)
-
- char *a; /* Ascii address. */
- struct ether_addr *ea; /* Ethernet Address. */
-
- {
- int o0;
- int o1;
- int o2;
- int o3;
- int o4;
- int o5;
-
- if (sscanf(a, "%x:%x:%x:%x:%x:%x", &o0, &o1, &o2, &o3, &o4, &o5) != 6)
- return (0);
-
- ea->ether_addr_octet[0] = o0;
- ea->ether_addr_octet[1] = o1;
- ea->ether_addr_octet[2] = o2;
- ea->ether_addr_octet[3] = o3;
- ea->ether_addr_octet[4] = o4;
- ea->ether_addr_octet[5] = o5;
- return (1);
- }
-
- /* ETHERnet address TO Ascii conversion. Note that the returned string */
- /* is kept in a static buffer, so copy it if you want to keep it! */
-
- extern char *
- ethertoa(ea)
-
- struct ether_addr *ea; /* Ethernet Address. */
-
- {
- static char addr[25]; /* ascii-ized ADDRess. */
-
- (void)sprintf(addr, "%02x:%02x:%02x:%02x:%02x:%02x",
- ea->ether_addr_octet[0],
- ea->ether_addr_octet[1],
- ea->ether_addr_octet[2],
- ea->ether_addr_octet[3],
- ea->ether_addr_octet[4],
- ea->ether_addr_octet[5]);
- return (addr);
- }
- \Rogue\Monster\
- else
- echo "will not overwrite ./ethertoa.c"
- fi
- if [ `wc -c ./ethertoa.c | awk '{printf $1}'` -ne 2122 ]
- then
- echo `wc -c ./ethertoa.c | awk '{print "Got " $1 ", Expected " 2122}'`
- fi
- echo "Finished archive 3 of 3"
- exit
-